import { aps } from '@/common/request';
import { formatter } from '@/common/request/formatter';

const { postRequest } = aps;

export class Service {
  async searchTree(payload: any): Promise<any[]> {
    const data = await postRequest('assignment/searchTree', payload);
    return formatter(data);
  }
  
  async search(payload: any): Promise<any[]> {
    const data = await postRequest('assignment/getAssignmentMesTaskList', payload);
    return formatter(data);
  }

  async getTaskInfo(payload: any): Promise<any> {
    const data = await postRequest('assignment/getTaskInfo', payload);
    return formatter(data);
  }

  async assignmentTask(payload: any): Promise<boolean> {
    const data = await postRequest('assignment/assignmentTask', payload);
    return formatter(data);
  }

  async getStationMBomScheduler(payload: any): Promise<boolean> {
    const data = await postRequest('work/getStationMBomScheduler', payload);
    return formatter(data);
  }

  async getUserMBomScheduler(payload: any): Promise<boolean> {
    const data = await postRequest('work/getUserMBomScheduler', payload);
    return formatter(data);
  }

  async getDeviceMBomScheduler(payload: any): Promise<boolean> {
    const data = await postRequest('work/getDeviceMBomScheduler', payload);
    return formatter(data);
  }

  async getCanAssignmentTask(payload: any): Promise<any> {
    const data = await postRequest('assignment/getCanAssignmentTask', payload);
    return formatter(data);
  }
  
  async getTaskResourceOccupyInfo(payload: any): Promise<any> {
    const data = await postRequest('assignment/getTaskResourceOccupyInfo', payload);
    return formatter(data);
  }
}
